/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package CastleDefense;

/**
 *
 * @author Firedemon
 */
import java.util.ArrayList;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;

//This statement means that class "MonsterList.java" is the root-element
@XmlRootElement(namespace = "MonsterList")
public class MonsterList
{
    // XmLElementWrapper generates a wrapper element around XML representation
    @XmlElementWrapper(name = "MonsterList")
    // XmlElement sets the name of the entities
    @XmlElement(name = "monster")
    private ArrayList<Monster> MonsterList;
    private ArrayList<Monster> tmpList = new ArrayList<Monster>();

    public void setMonsterList(ArrayList<Monster> MonsterList)
    {
        this.MonsterList = MonsterList;
    }

    public ArrayList<Monster> getMonstersList()
    {
        return MonsterList;
    }

    public void appendMonsterList(ArrayList<Monster> MonsterList)
    {
        for(int i=0; i<MonsterList.size(); i++)
        {
            tmpList.add(MonsterList.get(i));
        }
        this.MonsterList = tmpList;
    }

    public Monster getMonsterByName(String name)
    {
        for (Monster myMonster : MonsterList)
        {
            if(myMonster.getName().equals(name))
                return myMonster;
        }
        return null;
    }

    public String getSpriteByName(String name)
    {
        for (Monster myMonster : MonsterList)
        {
            if(myMonster.getName().equals(name))
                return myMonster.getSprite();
        }
        return null;
    }

    public Integer size()
    {
        return MonsterList.size();
    }
}
